<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    tr,td{
      border: 1px solid #000;
      padding: 5px;
    }
    a {
      display: inline-block;
      width: 100px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      text-decoration: none;
      border: 1px solid #000;
    }
  </style>
</head>
<body>
  <table>
    <tr>
      <th>id</th>
      <th>账号</th>
      <th>密码</th>
      <th>修改</th>
    </tr>
    <tbody>
      <% for(let item of data){ %>
      <tr>
        <td><%= item.id %></td>
        <td><%= item.username %></td>
        <td><%= item.password %></td>
        <td><a data-num="<%= item.id %>" onclick="deluser(this)" href="#">删除</a></td>
      </tr>
      <% } %>
    </tbody>
  </table>
</body>
</html>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
/* 
    $("a").on("click",function(){
      console.log( "ok");
    }) */
function deluser(that){
  console.log( that.dataset.num );
 let id =that.dataset.num;
   $.ajax({
    type: "get",
    url: "/deluser?id="+id,
    data: null,
    dataType: "json",
    success: function (response) {
      console.log( response );
      if( response.code==200){
        alert( response.msg );
      }else{
        alert( response.msg )
      }
    }
  });
}

</script>